cmake_minimum_required(VERSION 2.8.3)
project(dpptam)
add_definitions(-Wall -std=c++11 -Werror=return-type ${PCL_DEFINITIONS})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_BUILD_TYPE RelWithDebInfo)

set(CMAKE_BUILD_TYPE Debug)

find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Pangolin REQUIRED)
include_directories(
        include ${catkin_INCLUDE_DIRS}
        ${OpenCV_INCLUDE_DIRS}
        ${Eigen_INCLUDE_DIRS}
        ${PCL_INCLUDE_DIRS}
        ${Pangolin_INCLUDE_DIRS}
)
find_package(OpenMP)
if (OPENMP_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif ()


option(OPTIMIZATION "Enable optimization" FALSE)
if (OPTIMIZATION)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
    message("OPTIMIZATION FLAG ACTIVATED")
else ()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
    message("NO OPTIMIZATION FLAGS")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -pedantic  -Wcast-qual -Wpointer-arith -Winit-self -Wswitch-default -Wmissing-include-dirs -Wold-style-cast -Wnon-virtual-dtor -Wshadow -Wno-unknown-pragmas")

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -pedantic  -Wcast-qual -Wpointer-arith -Winit-self -Wswitch-default -Wmissing-include-dirs -Wold-style-cast -Wnon-virtual-dtor -Wshadow -Wno-unknown-pragmas")

link_directories(${PCL_LIBRARY_DIRS})

set(DENSE_SOURCE_FILES
        src/SemiDenseMapping.cpp
        src/DenseMapping.cpp
        src/SemiDenseTracking.cpp
        src/superpixel.cpp
        src/EurocReader.cpp
        src/ua_detrac_loader.cpp
        src/Viewer.cpp
        src/FrameDrawer.cc
        src/MapDrawer.cc
        )


set(DENSE_HEADER_FILES
        include/dpptam/SemiDenseMapping.h
        include/dpptam/DenseMapping.h
        include/dpptam/SemiDenseTracking.h
        include/dpptam/ua_detrac_loader.h
        include/dpptam/superpixel.h
        include/dpptam/Viewer.h
        )

set(THIRD_PARTY_LIBS
        ${OpenCV_LIBS}
        ${EIGEN3_LIBS}
        ${Pangolin_LIBRARIES}
        ${Boost_LIBRARIES}
        )

add_library(dpptam ${DENSE_HEADER_FILES} ${DENSE_SOURCE_FILES})
target_link_libraries(dpptam ${THIRD_PARTY_LIBS})

add_executable(test_euroc src/test_euroc.cpp)
target_link_libraries(test_euroc
        dpptam
        ${THIRD_PARTY_LIBS})
add_executable(test_ua_detrac src/test_ua_detrac.cpp)
target_link_libraries(test_ua_detrac
        dpptam
        ${THIRD_PARTY_LIBS})

add_executable(test_tum src/test_tum.cpp)
target_link_libraries(test_tum
        dpptam
        ${THIRD_PARTY_LIBS})